package org.grottarossa.template.drivers;

public class DriverException extends Exception
{
	private static final long serialVersionUID = -5578966255182227477L;

	/*
	private String[] ErrorCodeKey =
		new String[] { "OK", "KO", "QUERY_ERROR","CASEFOLDER_UPDT_CONFLICT","CASEFOLDER_CREATE_ERROR",
			"TASK_UPDATE_CONFLICT","TASK_UPDATE_ERROR","DISCUSSION_ERROREJB","ELEMENT_FROMBACKEND_NULL",
			"CONTENT_EJBERROR","CONTENT_NULL","CONTENT_UPDT_CONFLICT","BACKEND_CONNECTION_ERROR","INVALID_DATE","ID_CAST_ERROR","FORM_DATA_UPDATE_CONFLICT",
			"BUILDER_ERROR","WORK_FLOW_ERROR"
	};
	*/

	public enum ErrorCode
	{
		OK(0),
		KO(1),
		QUERY_ERROR(2),
		CASEFOLDER_UPDT_CONFLICT(3),
		CASEFOLDER_CREATE_ERROR(4),
		TASK_UPDATE_CONFLICT(5),
		TASK_UPDATE_ERROR(6),
		BACKEND_ERROREJB(7),
		ELEMENT_FROMBACKEND_NULL(8),
		CONTENT_EJBERROR(9),
		CONTENT_NULL(10),
		CONTENT_UPDT_CONFLICT(11),
		BACKEND_CONNECTION_ERROR(12),
		INVALID_DATE(13),
		ID_CAST_ERROR(14),
		FORM_DATA_UPDATE_CONFLICT(15),
		BUILDER_ERROR(16),
		WORK_FLOW_ERROR(17);



		private int val;

		ErrorCode(int val)
		{
			this.setVal(val);
		}

		public void setVal(int val) {
			this.val = val;
		}

		public int getVal() {
			return val;
		}
	}

	private ErrorCode errorCode = ErrorCode.OK;
	private String args = "";

	public DriverException(String javaError, ErrorCode errCode, String sArgs)
	{
		super(javaError);
		this.errorCode = errCode;
		this.setArgs(sArgs);
	}

	public DriverException(String javaError, ErrorCode errCode)
	{
		super(javaError);
		this.errorCode = errCode;
	}

	public ErrorCode getErrorCode()
	{
		return errorCode;
	}

	public void setArgs(String args) {
		this.args = args;
	}

	public String getArgs() {
		return args;
	}
}
